package com.ichart.doc;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.ichart.html.HtmlApi;
import com.ichart.js.ScriptHelp;
import com.ichart.utils.FileUtils;

public class DocBuilder {
	
	public static ComponentResolver resolver = new ComponentResolver();
	public static Api api = new HtmlApi();
	
	public static void bulid(){
		List<String> listjs = ScriptHelp.getChartJs();
		List<String> pluginjs = ScriptHelp.getPluginJs();
		List<Component> All = new ArrayList<Component>();
		try {
			for (String string : listjs) {
				All.addAll(resolver.resolver(FileUtils.readFileToString(new File(Info.SrcPath +string))));
			}
			for (String string : pluginjs) {
				All.addAll(resolver.resolver(FileUtils.readFileToString(new File(Info.PluginPath +string))));
			}
			api.create(All,Info.DOCUMENT);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void chinese(){
		Info.setLanguage(Info.CHINESE);
		Info.setSrcPath("E:/workspace8.6/ichartJava/src/js/");
		bulid();
	}
	
	public static void english(){
		Info.setLanguage(Info.ENGLISH);
		Info.setSrcPath("E:/workspace8.6/ichartjs/src/");
		bulid();
	}
	public static void ichartjs(){
		Info.setTargetPath("E:/workspace8.6/ichartjs/");
		//build api for chinese
		chinese();
		//build api for english
		english();
	}
	
	public static void ichartjsHome(){
		Info.setTargetPath("E:/workspace8.6/ichartjsHome/");
		//build api for chinese
		chinese();
		//build api for english
		english();
	}
	
	public static void main(String[] args) {
		ichartjs();
		
		ichartjsHome();
	}
	
}
